#include <cpr/cpr.h>
#include <iostream>
#include <chrono>

int main(int argc, char** argv) {
    auto start_time = std::chrono::high_resolution_clock::now();
    cpr::Response r = cpr::Get(cpr::Url{"https://www.okex.com/api/v5/market/books"},
                                cpr::Parameters{{"instId","XRP-USDT-SWAP"},{"sz","100"}});
    std::cout << "r.status_code " << r.status_code << std::endl;                  // 200
    std::cout << "r.header['content-type'] " << r.header["content-type"] << std::endl;       // application/json; charset=utf-8
    std::cout << "r.text " << r.text << std::endl;                         // JSON text string
    auto end_time = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end_time - start_time);

    std::cout << "the consume time of cpr requests: " << duration.count()/1000.0 << " ms" << std::endl;
    return 0;
}